<div id="wrapper">
    <div id="page-wrapper">
        <div class="panel panel-primary">
            <div class="panel-heading"><h5 class="panel-title"></h5></div>
            <div class="panel-body">
                <div id="toolbar" class="ms-toolbar">
                    <button id="toolbar-add" class="btn btn-danger" data-toggle="modal" data-target="#addBanner">
                        <span class="glyphicon glyphicon-plus"></span> 增加
                    </button>
                </div>
                <div class="modal fade" id="addBanner" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                     aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"
                                        aria-hidden="true">&times;</button>
                                <h4 class="modal-title">增加广告位</h4>
                            </div>
                            <div class="modal-body">
                                <form id="addForm" class="form-horizontal">
                                    <div class="form-group">
                                        <label for="position_name" class="col-sm-2 control-label">名称</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" id="position_name"
                                                   name="position_name" placeholder="必填项，广告名称">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="position_desc" class="col-sm-2 control-label">描述</label>

                                        <div class="col-sm-10">
                                            <input type="text" class="form-control" id="position_desc"
                                                   name="position_desc" placeholder="必填项，广告简要描述">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="position_desc" class="col-sm-2 control-label">描述</label>

                                        <div class="col-sm-10">
                                            <select name="is_default" class="form-control">
                                                <option value="1">非默认</option>
                                                <option value="0">默认</option>
                                            </select>
                                            <span id="helpBlock" class="help-block">默认广告位无法删除以及关闭</span>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button id="close" type="button" class="btn btn-primary" data-dismiss="modal">关闭
                                </button>
                                <button id="add_confirm" type="button" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </div>
                </div>
                <table class="table table-bordered ">
                    <thead>
                    <th>bannerID</th>
                    <th>名称</th>
                    <th>描述</th>
                    <th>开关</th>
                    <th>默认</th>
                    <th>操作</th>
                    </thead>

                    <tbody>
                    {%notempty name="data"%}
                    <tr>
                        {%volist name="data->all()" id="vo"%}
                        <td>{%$vo.position_id%}</td>
                        <td>{%$vo.position_name%}</td>
                        <td>{%$vo.position_desc%}</td>
                        <td>
                            {%switch name="$vo.is_open"%}
                            {%case value="0"%}关{%/case%}
                            {%case value="1"%}开{%/case%}
                            {%/switch%}
                        </td>
                        <td>
                            {%switch name="$vo.is_default"%}
                            {%case value="0"%}是{%/case%}
                            {%case value="1"%}否{%/case%}
                            {%/switch%}
                        </td>
                        <td style="width: 118px;">
                            {%switch name="$vo.is_open"%}
                            {%case value="0"%}
                            <button class="openbanner btn btn-danger btn-sm">开启</button>
                            {%/case%}
                            {%case value="1"%}
                            <button class="closebanner btn btn-danger btn-sm">关闭</button>
                            {%/case%}
                            {%/switch%}


                            <button class="delbanner btn btn-danger btn-sm">删除</button>
                        </td>
                    </tr>
                    {%/volist%}
                    </tbody>
                </table>
                <div class="pull-right">
                    {%$data->render()%}
                </div>
                {%/notempty%}
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id='deleteModal' tabindex="-1" role="dialog">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">确认删除</h4>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">取消</button>
                <button id="delete_confirm" type="button" class="btn btn-danger">确认</button>
            </div>
        </div>
    </div>
</div>
<script src="/static/home/widget/management/bannerlist/bannerlist.js"></script>
<script src="/static/home/widget/management/bannerlist/editbanner.js"></script>
